﻿/*******************************************************************************
 * Copyright © 2016 DJY 版权所有
 * Author: DJY
 * Description: 后台管理系统
 * Website：http://www.djyweb.cn
*********************************************************************************/
using DJY.Code;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;

namespace DJY.Data
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="TEntity">实体类型</typeparam>
    public interface IDbRepository<TEntity> where TEntity : class,new()
    {
        int Insert(DbContext db,TEntity entity);
        int Insert(DbContext db, List<TEntity> entitys);
        int Update(DbContext db, ICollection<string> columns, TEntity entity);
        int Update(DbContext dbcontext, ICollection<string> columns, List<TEntity> entities);
        int Delete(DbContext db, TEntity entity);
        int Delete(DbContext db, List<TEntity> entitys);
        int Delete(DbContext db, Expression<Func<TEntity, bool>> predicate);
        TEntity FindEntity(DbContext db, Expression<Func<TEntity, bool>> predicate);
        IQueryable<TEntity> IQueryable(DbContext db);
        IQueryable<TEntity> IQueryable(DbContext db, Expression<Func<TEntity, bool>> predicate);
        List<TEntity> FindList(DbContext db, string strSql);
        List<TEntity> FindList(DbContext db, string strSql, DbParameter[] dbParameter);
        List<TEntity> FindList(DbContext db, Pagination pagination);
        List<TEntity> FindList(DbContext db, Expression<Func<TEntity, bool>> predicate, Pagination pagination);
    }
}
